var layerId;
var clickState = true;
$(function(){
	$("#save-button").click(function(){
		var parentId = $("select[name='parentId']").val();
		var englishName = $("input[name='englishName']").val();
		var name = $("input[name='name']").val();
		var icon = $("#imageUrl").attr("data-img");
		if(name.length == 0){
			layer.msg("请输入类型名称");
			return false;
		}
		if(englishName.length == 0){
			layer.msg("请输入英文名称");
			return false;
		}
		if(parentId.length==0){
			layer.msg("请选择上级分类");
			return false;
		}
		if(icon.length == 0){
			layer.msg("请上传类型图");
			return false;
		}
		var typeId=init.typeId;
		var grade=init.grade;
		var isUsed=init.isUsed;
		var typeData ={
			"id":typeId,
			"grade":grade,
			"name":name,
			"englishName":englishName,
			"parentId":parentId,
			"isUsed":isUsed,
			"icon":icon,
			"isUsed":isUsed
		}
		if(clickState){
			clickState = false;
			$.ajax({
				url:basePath+"/goodsType/save.shtml",
				data:typeData,
				type:"post",
				dataType:"JSON",
				success:ajaxSuccessCloseFun
			});
		}
	});
	$("#close-button").click(function(){
		parent.closeLayer(0);
	});
	
});
